package com.zzty.zzlp.dao;

import com.zzty.zzlp.entity.TeamExamTransation;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface TeamExamTransationMapper {
    @Select("select * from teamexamtransation where examId=#{examId} and userIds=#{userIds}")
    public TeamExamTransation getInfoByExamIdandUserIds(@Param("examId") Integer examId, @Param("userIds") String userIds);

    @Update("update teamexamtransation set state=#{state} where examId=#{examId} and userIds=#{userIds}")
    public void updateStateByExamIdAndUserIds(TeamExamTransation tet);

    @Update("update teamexamtransation set startTime=#{startTime} where examId=#{examId} and userIds=#{userIds}")
    public void updateStartTimeByExamIdAndUserIds(TeamExamTransation tet);

    @Update("update teamexamtransation set answers=#{answers} where examId=#{examId} and userIds=#{userIds}")
    public void updateAnswerByExamIdAndUserIds(TeamExamTransation tet);

    @Update("update teamexamtransation set totalTime=#{totalTime} where examId=#{examId} and userIds=#{userIds}")
    public void updateTotaiTime(TeamExamTransation tet);

    @Update("update teamexamtransation set isValid=#{isValid} where examId=#{examId} and userIds=#{userIds}")
    public void updateIsValidByExamIdAndUserIds(TeamExamTransation tet);

    @Update("update teamexamtransation set score=#{score} where examId=#{examId} and userIds=#{userIds}")
    public void updateScoreByExamIdAndUserIds(TeamExamTransation tet);

    @Update("update teamexamtransation set comment=#{comment} where examId=#{examId} and userIds=#{userIds}")
    public void updateCommentByExamIdAndUserIds(TeamExamTransation tet);

    @Select("select comment from teamexamtransation where examId = #{examId} and userIds = #{userIds}")
    public String searchComment(@Param("examId") Integer examId, @Param("userIds") String userIds);

    @Select("select * from teamexamtransation where examId=#{examId}")
    public List<TeamExamTransation> searchInfoByExamId(Integer examId);

    @Insert("insert into teamexamtransation (examId,userIds) values(#{examId},#{userIds})")
    public void addTeamExamTransation(TeamExamTransation tet);

    @Select("SELECT * FROM teamexamtransation,teamexam WHERE teamexam.id = examId AND date = #{date};")
    public List<TeamExamTransation> searchUserIds(String date);

    @Update("update teamexamtransation set rank=1 where examId=#{examId} and score='A'")
    public void updateRank(Integer examId);

    @Select("select userIds from teamexamtransation where examId=#{examId} and score='A'")
    public String searchWinnerIds(Integer examId);


}
